<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <canvas id="cont" width="1000px" , height="1000px">您的浏览器版本太低，不支持画布，请更新浏览器</canvas>
    <script>
        //固定的两步
        var canvas = document.querySelector('#cont')
        var ctx = canvas.getContext('2d')

        //1.画杯身
        ctx.lineWidth = 3
        ctx.strokeStyle = 'green'
        ctx.strokeRect(100, 200, 200, 200)
        ctx.beginPath();
        ctx.moveTo(100, 280)
        ctx.lineTo(300, 280)
        ctx.moveTo(100, 350)
        ctx.lineTo(300, 350)
        ctx.stroke()

        //2.画把手
        drawCircle(300, 300, 50, 10, false, 'orange')

        //3.画热气
        // drawCircle(120,120,20,1,true)
        // drawCircle(120,160,20,1,false)

        // drawCircle(160,120,20,1,true)
        // drawCircle(160,160,20,1,false)

        // drawCircle(200,120,20,1,true)
        // drawCircle(200,160,20,1,false)

        // drawCircle(240,120,20,1,true)
        // drawCircle(240,160,20,1,false)

        for (var i = 0; i < 4; i++) {
            drawCircle(130 + i * 40, 120, 20, 1, true, 'blue')
            drawCircle(130 + i * 40, 160, 20, 1, false, 'blue')
        }

        //画半圆弧
        function drawCircle(x, y, r, width, flag, color) {
            ctx.beginPath()
            ctx.arc(x, y, r, -Math.PI / 2, Math.PI / 2, flag)
            ctx.lineWidth = width
            ctx.strokeStyle = color || 'red'
            ctx.stroke()


        }

    </script>
</body>

</html>